package com.jmd.model.task;

import java.io.Serial;
import java.io.Serializable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

import lombok.Data;

@Data
public class TaskAllInfoEntity implements Serializable {

	@Serial
	private static final long serialVersionUID = 6301744429585359593L;

	private String tileUrl = "";
	private String TK = "";
	private String tileName;
	private String mapType;
	private Integer imgType;
	private String oriImgType;
	private String savePath;
	private String pathStyle;
	private Boolean isCoverExists;
	private Boolean isMergeTile;
	private Integer mergeType;
	private Integer errorHandlerType;
	private Long allRealCount;
	private Long allRunCount;
	private ConcurrentHashMap<Integer, TaskInstEntity> eachLayerTask;
	private ConcurrentHashMap<String, ErrorTileEntity> errorTiles;

	public String getTK() {

		String regex = "tk=.*";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(this.tileUrl);
		if (matcher.find()) {
			this.TK = matcher.group().replace("tk=", "");
		}
		return this.TK;
	}

	public void setTK(String _tk) {
		String new_tk = "tk=" + _tk;
		String old_tk = "tk=" + this.TK;
		this.tileUrl = this.tileUrl.replace(old_tk, new_tk);
		this.TK = _tk;
	}

}
